﻿	      <?php include("conn.php");
	      include("func/request.php");
             mysql_query('SET NAMES UTF8'); 

   $tel=$_REQUEST[tel];
   $password=$_REQUEST[pass];
 
	$rert30=mysql_query("select * from shop where  (phone='".$tel."' or shop_daima='".$tel."')  and password='".$password."'");
	$prize = array();
	$rowf=mysql_fetch_array($rert30);

	if($rowf!=false){
	 	if ($rowf[check] == 1) {
	 		$false=100;
	 	}elseif ($rowf[check] == 0) {
	 		$false=400;
	 	}elseif ($rowf[check] == 2) {
	 		$false=300;
	 		$reason = $rowf[reason];
	 	}
	 }else{
	  $false=200;
	 }

    $url = "http://www.ewangpf.com/api/rongcloud/API/haha.php?uid=sid-".$rowf[shopid]."&uname=".$rowf[name]."&headimg=".$rowf[head_pic];
	$url_ret = file_get_contents($url);
	$tokenObj = json_decode($url_ret);
	$token = $tokenObj->token;
	mysql_query("update shop set pw_token='".$token."' where  shopid=".$rowf['shopid']);
    //重新检索该条记录
    $rert30=mysql_query("select * from shop  where  shopid=".$rowf['shopid']);
	$rowf=mysql_fetch_array($rert30);

	if ($false==300) {
		$arr = array('shopid' => $rowf['shopid'],'result' => $false ,'token' => $rowf['pw_token'], 'reason' => $reason);
	}else {
		$arr = array('shopid' => $rowf['shopid'],'token' => $rowf['pw_token'], 'result' => $false);
	}

 echo json_encode($arr);
?>